package tech.chuangxiang.weichuangxin;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class ShowWebActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_web);
        //新页面接收数据
        Bundle bundle = this.getIntent().getExtras();
        //接收name值
        String url = bundle.getString("url");
        WebView show_webinfo = (WebView) findViewById(R.id.show_webinfo);
        set_selfopen(show_webinfo);
        // set_selfopen(imglist);
        WebSettings wSet = show_webinfo.getSettings();
        wSet.setJavaScriptEnabled(true);
        show_webinfo.loadUrl(url);
    }

    public void set_selfopen(WebView webView){
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }
        });
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.mainweb,menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()){
            case R.id.back_item:
                finish();
                break;
            default:

                break;
        }
        return true;
    }
}
